package com.kunsan.compose.widget

import androidx.compose.foundation.Image
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.WindowInsets
import androidx.compose.foundation.layout.fillMaxHeight
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.statusBars
import androidx.compose.material3.CenterAlignedTopAppBar
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.material3.TopAppBarDefaults
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.unit.dp
import com.kunsan.compose.R
import com.kunsan.compose.ui.theme.AppBarBackground

@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun ChatAppBar(modifier: Modifier = Modifier) {
//    Row(
//        modifier = modifier
//            .fillMaxWidth()
//            .height(50.dp)
//            .background(AppBarBackground),
//        verticalAlignment = Alignment.CenterVertically
//
//    ) {
//        Image(painter = painterResource(id = R.drawable.icon_camera_switch), contentDescription = "switch")
//        Text(text = "Chat", textAlign = TextAlign.Center, modifier = Modifier.weight(1f), color = Color.White)
//    }

    CenterAlignedTopAppBar(
        modifier = Modifier
            .fillMaxWidth()
            .height(80.dp),
        colors = TopAppBarDefaults.centerAlignedTopAppBarColors(
            containerColor = AppBarBackground
        ),
        windowInsets = WindowInsets.statusBars,
        navigationIcon = {
            Box(
                modifier = Modifier.fillMaxHeight().padding(8.dp),
                contentAlignment = Alignment.Center
            ) {
                Image(
                    painter = painterResource(id = R.drawable.icon_camera_switch),
                    contentDescription = "switch"
                )
            }

        },
        title = {
            Box(
                modifier = Modifier.fillMaxHeight(),
                contentAlignment = Alignment.Center
            ) {
                Text(
                    text = "Chat",
                    style = MaterialTheme.typography.titleSmall,
                    color = Color.White
                )
            }
        },
    )
}